import time, yagmail, XTestRunner, glob


class Tools():

    def Report(self):
        t = time.strftime('%Y%m%d%H%M%S', time.localtime())
        html_file = rf'D:\zhuangaoliu\gaoweiyk_ui\Report\{t}.html'
        report = XTestRunner.HTMLTestRunner(open(html_file, 'wb'), title='客户管理系统UI自动化测试报告', description='测试报告')
        return report

    def mail(self):
        attachments = glob.glob(rf'D:\zhuangaoliu\gaoweiyk_ui\Report\*html')
        mail = yagmail.SMTP(user='2318636512@qq.com', password='lmakcmojpqpjdhhj', host='smtp.qq.com')
        mail.send(to='2318636512@qq.com', subject='关于客户管理系统的测试报告', contents='UI自动化测试报告', attachments=attachments)
        mail.close()








